Skip to content

C#: Replace SSA classes with shared code.#21762

Open
aschackmull wants to merge 28 commits intogithub:mainfrom
aschackmull:csharp/ssa2
Open

C#: Replace SSA classes with shared code.#21762
aschackmull wants to merge 28 commits intogithub:mainfrom
aschackmull:csharp/ssa2

Conversation

@aschackmull
Copy link
Copy Markdown
Contributor

@aschackmull aschackmull commented Apr 28, 2026

This aligns the C# SSA classes with the shared SSA signature by using the classes provided by the shared library.

@github-actions github-actions Bot added the C# label Apr 28, 2026
@aschackmull aschackmull force-pushed the csharp/ssa2 branch 2 times, most recently from ef22df2 to 7b3cdc8 Compare April 29, 2026 07:52
@aschackmull aschackmull marked this pull request as ready for review May 1, 2026 11:15
@aschackmull aschackmull requested a review from a team as a code owner May 1, 2026 11:15
Copilot AI review requested due to automatic review settings May 1, 2026 11:15
@aschackmull aschackmull requested a review from a team as a code owner May 1, 2026 11:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the C# SSA library to the shared SSA signature by switching C# SSA consumers to shared SSA classes (for example SsaDefinition, SsaExplicitWrite, SsaPhiDefinition) and deprecating the legacy C#-specific SSA wrapper classes.

Changes:

  • Update shared SSA toString() for SSA definitions (including phi definitions) to match the shared formatting.
  • Rework the C# SSA library surface to expose shared SSA types and add migration helpers (for example Ssa::ssaGetAFirstUse), while deprecating legacy types/APIs.
  • Bulk-update C# queries and test queries/expectations to the new SSA API and renamed classes.
Show a summary per file
File Description
shared/ssa/codeql/ssa/Ssa.qll Adjust SSA definition/phi toString() formatting in the shared SSA library.
csharp/ql/test/library-tests/dataflow/ssa/SsaUltimateDef.ql Update test query to use shared SSA definition types.
csharp/ql/test/library-tests/dataflow/ssa/SsaUltimateDef.expected Update expected output for renamed SSA types / locations.
csharp/ql/test/library-tests/dataflow/ssa/SsaRead.ql Update test query to use SsaDefinition.
csharp/ql/test/library-tests/dataflow/ssa/SsaRead.expected Update expected output for shared SSA API changes.
csharp/ql/test/library-tests/dataflow/ssa/SsaImplicitQualifier.expected Update expected output for qualifier SSA behavior/printing changes.
csharp/ql/test/library-tests/dataflow/ssa/SsaImplicitParameterDef.ql Update test query to use SsaParameterInit.
csharp/ql/test/library-tests/dataflow/ssa/SsaExplicitDef.ql Update test query to use SsaExplicitWrite and new accessor names.
csharp/ql/test/library-tests/dataflow/ssa/SsaExplicitDef.expected Update expected output for explicit write changes.
csharp/ql/test/library-tests/dataflow/ssa/SsaDefElement.ql Remove obsolete test query relying on legacy SSA API.
csharp/ql/test/library-tests/dataflow/ssa/SsaDefElement.expected Remove corresponding obsolete expected file.
csharp/ql/test/library-tests/dataflow/ssa/SsaDef.ql Update test query to use SsaDefinition.
csharp/ql/test/library-tests/dataflow/ssa/SsaDef.expected Update expected output for SsaDefinition output changes.
csharp/ql/test/library-tests/dataflow/ssa/SSAPhi.ql Update phi test query to use SsaPhiDefinition/SsaDefinition.
csharp/ql/test/library-tests/dataflow/ssa/SSAPhi.expected Update expected output for phi definition formatting/locations.
csharp/ql/test/library-tests/dataflow/ssa/IsLiveOutRefParameterDefinition.ql Switch from method call to Ssa::isLiveOutRefParameterDefinition(def, p) helper.
csharp/ql/test/library-tests/dataflow/ssa/DefAdjacentRead.expected Update expected output for SSA adjacency results after migration.
csharp/ql/test/library-tests/dataflow/ssa/BaseSsaConsistency.ql Update SSA consistency test to use shared write types.
csharp/ql/test/library-tests/dataflow/ssa-large/countssa.ql Update SSA large-count test to use SsaExplicitWrite.
csharp/ql/test/library-tests/dataflow/local/TaintTrackingStep.expected Update expected taint-tracking steps for shared SSA API changes.
csharp/ql/test/library-tests/dataflow/local/DataFlowStep.expected Update expected data-flow steps for shared SSA API changes.
csharp/ql/test/library-tests/dataflow/defuse/useUseEquivalence.ql Update def/use equivalence test to shared SSA types and helper for first use.
csharp/ql/test/library-tests/dataflow/defuse/parameterUseEquivalence.ql Update parameter-use equivalence test to SsaParameterInit.
csharp/ql/test/library-tests/dataflow/defuse/defUseEquivalence.ql Update def/use equivalence test to shared explicit write type/accessors.
csharp/ql/test/library-tests/dataflow/callablereturnsarg/Common.qll Update out/ref tracking helper to shared SSA write types and predicates.
csharp/ql/test/library-tests/csharp7/LocalTaintFlow.expected Update expected flow steps for SSA locations/formatting changes.
csharp/ql/test/library-tests/csharp7/DefUse.ql Update C#7 def/use test to shared SSA definition types.
csharp/ql/src/Likely Bugs/Dynamic/BadDynamicCall.ql Update query to shared SSA types/accessors to resolve ultimate definition.
csharp/ql/src/Dead Code/DeadStoreOfLocal.ql Update query to treat SSA explicit writes via SsaExplicitWrite.
csharp/ql/src/Bad Practices/Control-Flow/ConstantCondition.ql Switch constant-condition integration to shared SSA definition class reference.
csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaUtils.qll Update range analysis SSA utilities to shared SSA types and accessors.
csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaReadPositionSpecific.qll Update SSA type aliases to CS::SsaDefinition / CS::SsaPhiDefinition.
csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll Update sign analysis SSA types and explicit write handling to shared SSA API.
csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/RangeUtils.qll Update range utilities to shared SSA definition types.
csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/ModulusAnalysisSpecific.qll Update modulus analysis to use shared SsaPhiDefinition.
csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll Refactor C# SSA implementation to use shared SsaImplCommon input signature and provide deprecated compatibility shims.
csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll Update internal data-flow SSA integration points to shared SSA types and helper predicates.
csharp/ql/lib/semmle/code/csharp/dataflow/internal/BaseSSA.qll Restructure BaseSSA to expose SSA via shared implementation modules.
csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll Re-export shared SSA API from the public C# SSA library; add migration helper(s) and deprecations.
csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll Update nullness analysis to shared SSA types and new first-use logic.
csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll Simplify guard SSA integration by importing Ssa rather than duplicating SSA wrapper classes.
csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowReachability.qll Switch reachability integration to import Ssa shared SSA types.
csharp/ql/lib/semmle/code/csharp/Assignable.qll Update AssignableDefinition.getAFirstRead implementation to use Ssa::ssaGetAFirstUse.
csharp/ql/lib/change-notes/2026-05-01-ssa-replacement.md Add change note documenting SSA rename/deprecation and migration guidance location.
csharp/ql/consistency-queries/SsaConsistency.ql Update consistency query to use SsaExplicitWrite and new accessors.

Copilot's findings

  • Files reviewed: 45/45 changed files
  • Comments generated: 1

}

/**
* Allows for flow into uncertain defintions that are not call definitions,
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the doc comment: "defintions" should be "definitions".

Suggested change
* Allows for flow into uncertain defintions that are not call definitions,
* Allows for flow into uncertain definitions that are not call definitions,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants